package com.evenmo.springjpademo.config;

import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * This is Description 配置JPA，类似于配置mybatis实体类和对应的映射器接口，EnableJpaRepositories和EntityScan
 *
 * @author moyongjun
 * @date 2019/12/03
 */
@Configuration
@Order(Ordered.HIGHEST_PRECEDENCE)
@EnableTransactionManagement(proxyTargetClass = true)
@EnableJpaRepositories(basePackages ="com.evenmo.springjpademo.repository")
@EntityScan(basePackages ="com.evenmo.springjpademo.entity")
public class JPAConfiguration {

@Bean
    PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor(){
    return new PersistenceExceptionTranslationPostProcessor();
}

}
